﻿using System;
using System.Collections.Generic;
using System.Collections; 
using System.Linq;
using System.Text;

namespace ElevatorSimCSharp
{
    class Floor
    {
        private short thisFloor;
        private string name;
        private int numberOfPeopleWaiting;
        private List<Person> peopleGoTo = new List<Person>();

        public Floor()
        {
            thisFloor = 0;
            name = "";
            numberOfPeopleWaiting = 0;
        }

        public Floor(short floorNumber)
        {
            this.thisFloor = floorNumber;
            this.name = "Floor " + this.thisFloor;
        }

        public Floor(string name, short floorNumber)
        {
            this.name = name;
            this.thisFloor = floorNumber;
        }

        public void initializeFloor(string name, short floorNumber) {
            this.name = name;
            this.thisFloor = floorNumber;
        }

        public void initializeFloor(short floorNumber)
        {
            this.thisFloor = floorNumber;
            this.name = "Floor " + this.thisFloor;
        }

        public void addPerson(Person person)
        {
            peopleGoTo.Add(person);
        }

        public List<Person> getPersonsList()
        {
            return peopleGoTo;
        }

        public void setPersonsList(List<Person> peopleList)
        {
            peopleGoTo = peopleList;
        }
        public void generatePerson() 
        {
            peopleGoTo.Add(new Person());
        }

        public void setName(string name)
        {
            this.name = name;
        }

        public short getFloorNumber()
        {
            return thisFloor;
        }

        public void movePeopleToElevator(sbyte direction, Elevator elevator) 
        {
            foreach (Person person in peopleGoTo)
            {
                if (direction < 0 && person.getWantToGoTo() - this.thisFloor < 0) 
                {
                    elevator.addPerson(person);
                    peopleGoTo.Remove(person);
                }
                else
                {
                    elevator.addPerson(person);
                    peopleGoTo.Remove(person);
                }
            }
        }
    }
}
